package embyparse.parsetree;

import java.util.ArrayList;

import embyparse.noobparser.Pattern;
import embyparse.tokenizer.Token;

public class ParseNode {

	public Pattern tag;

	public Token value;
	public int lineNumber;
	public ArrayList<ParseNode> children;

	private boolean isOperator;
	public ParseNode(Pattern tag, Token val, ArrayList<ParseNode> children){
		this.tag = tag;
		this.value = val;
		lineNumber = -1;
		if(val!=null){
			lineNumber = value.line();
		}
		this.children=children;
		isOperator = false;
	}

	public ParseNode setLine(int i){
		lineNumber = i;
		return this;
	}

	public ParseNode setInfixOperator(boolean b){
		isOperator = b;
		return this;
	}
	public boolean isInfixOperator(){
		return isOperator;
	}

	public String toString(){
		if( tag.getName().equals("VAR")){
			return "VAR:"+lineNumber+":"+value;
		}
		return tag.getName()+":"+lineNumber;
	}

}
